package jmine.tec.subscription.impl;

import java.io.Serializable;

import jmine.tec.subscription.SubscriptionSet;

/**
 * Representacao (ou snapshot) de um {@link SubscriptionSet} que eh {@link Serializable}
 * 
 * @author takeshi
 */
public class SubscriptionSetRepresentation implements SubscriptionSet, Serializable {
    private static final long serialVersionUID = 9096080424752792616L;

    private final long token, version, timeout;

    /**
     * C'tor
     * 
     * @param token o token
     * @param version a versao
     * @param timeout timeout
     */
    public SubscriptionSetRepresentation(long token, long version, long timeout) {
        super();
        this.token = token;
        this.version = version;
        this.timeout = timeout;
    }

    /**
     * {@inheritDoc}
     */
    public long getToken() {
        return this.token;
    }

    /**
     * {@inheritDoc}
     */
    public long getVersion() {
        return this.version;
    }

    /**
     * {@inheritDoc}
     */
    public boolean isExpired() {
        return System.currentTimeMillis() > this.timeout;
    }

    /**
     * {@inheritDoc}
     */
    public long nextTimeout() {
        return this.timeout;
    }

    /**
     * no-op
     */
    public void renewTimeout() {
    }

}
